package day63_260;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

/**
 * @ClassName Solution
 * @Description 哈希表
 * @Author clockTown
 * @Date 2021/7/11 18:54
 * @Version 1.0
 */
public class Solution {
    public int[] singleNumber(int[] nums) {
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int num : nums) {
            map.put(num, map.getOrDefault(num, 0) + 1);
        }

        ArrayList<Integer> list = new ArrayList<>();
        for (Integer key : map.keySet()) {
            if (map.get(key) == 1) {
                list.add(key);
            }
        }

        return list.stream().mapToInt(Integer::intValue).toArray();
    }
}
